<?php
/**
 * 
 * @author yuxun
 *
 */

class RoleInfoController extends AdminBaseController {
	
	public function index(){
		$filter = new PubFilter();
		$grid = new PubGrid();
		
		$lod_special_id = $this->R('special_id');
		$lodos = $this->R('os');
		$filter->addSpecialFilter(false,1);
		$filter->addOsFilter($lod_special_id,true,1);
		$filter->addServerFilter($lod_special_id,$lodos,false,false,1)
		->addExport();
	
		$filter->addFilter('RoleId', 'input', 'RoleId');
		$filter->addFilter('RoleName', 'input', '角色名称');
	
		$this->setTitle('开服前7天角色信息');
		$params = $filter->get();
		$params = $this->logCommon($params);
		
		
		//查询所选服的开服日期
		$modServer = new ModServer();
		$server_obj = $modServer->findByAttributes(array('develop_id'=>$params['server']));
		if($server_obj){
			$open_time = $server_obj->open_time;
			$open_time  = date('Y-m-d',$open_time);   //开服第1天
			$seven_open_time = date('Y-m-d', strtotime($open_time . ' +6 day'));  //开服第7天
			
			$params['open_time'] = $open_time;
			$params['seven_open_time'] = $seven_open_time;
		}
		//查询所选服的开服日期

		$header = RoleInfoService::indexHeader($params);
		if($filter->isExport()){
			ini_set('memory_limit','1024M');
			$result = RoleInfoService::indexData($params);
			LibExcel::exportCsv($header, $result, "Mango数据后台-开服前7天({$params['time_start']}).csv");
			exit();
		}else{
			$result = RoleInfoService::indexData($params);
			$order  = 'CreateTime';
			$grid->addGrid($header, $result, array(
					'name'=>'数据',
					'order'=>array($order, 'asc'),
					'type'=>'roleInfo/index',
					'length'=>50,
					'page'=>$page,
					'fix'   => array(
							'col' => 3
					)
			));
	
			$this->out['grid'] = $grid->show();
			$this->out['filter'] = $filter->show();
	
			$this->out['is_log'] = 1;
		}
	}
	
	
	
	
	
    

    


} 
